package controllers

import (
	"github.com/astaxie/beego"
	"fmt"
	"wcy-xmt-api/models"
)

// 图文直播
type ImgTxtLiveController struct {
	beego.Controller
}

// @Title 开始图文直播
// @Description 开始图文直播
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param chanId form int true "频道id"
// @Param token form string true "登陆成功token"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.StartStatus
// @router /start [post]
func (this *ImgTxtLiveController) Start() {
	fmt.Println("run ImgTxtLiveController Start")
	resStatus := &models.ResStatus{}
	startStatus := &models.StartStatus{}
	startStatus.Code = 0
	startStatus.SessionId = 232423423;
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title 获取图文直播频道列表
// @Description 获取图文频道列表
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.Channels
// @router /changes [post]
func (this *ImgTxtLiveController) Changes() {
	fmt.Println("run ImgTxtLiveController Changes")

	resStatus := &models.ResStatus{}
	channels := &models.Channels{}
	chanes := []*models.Channel{}

	channel := &models.Channel{1, "2016马拉松直播"}
	chanes = append(chanes, channel)
	channel = &models.Channel{2, "NBA总决赛"}
	chanes = append(chanes, channel)
	channel = &models.Channel{3, "直播大丰收"}
	chanes = append(chanes, channel)
	channel = &models.Channel{4, "百度夏季Party"}
	chanes = append(chanes, channel)
	channel = &models.Channel{5, "五马街闹元宵"}
	chanes = append(chanes, channel)

	channels.Code = 0
	channels.Data = chanes
	channels.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = channels
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title 获取最新条目
// @Description 获取最新条目
// @Param app form int true "App编号"
// @Param size form int true "请求条目数"
// @Param current_page form int true "当前Page"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.Comments
// @router /list [post]
func (this *ImgTxtLiveController) List() {
	fmt.Println("run ImgTxtLiveController list")

	resStatus := &models.ResStatus{}
	commons := &models.Comments{}

	commes := []*models.Comment{}
	common := &models.Comment{}
	common.Id = 01
	common.Content= "嗯，这个美女不错"
	common.Name = "Shily杨"
	common.Time = "14:30"
	common.Imgs = []string{"http://g.hiphotos.baidu.com/image/pic/item/c8ea15ce36d3d539d090d5353f87e950342ab093.jpg", "http://image.tianjimedia.com/uploadImages/2016/050/53/3BTO2P1Q2703.jpg", "http://www.sc.xinhuanet.com/content/2016-02/19/1118100732_14558716576211n.jpg"}

	commes = append(commes,common)
	commes = append(commes,common)
	commes = append(commes,common)
	commes = append(commes,common)
	commes = append(commes,common)

	commons.Code = 0
	commons.CurPage = 1
	commons.Data = commes
	commons.ErrMsg = ""
	commons.Total = 5

	resStatus.Code = 200
	resStatus.Data = commons
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title 发布
// @Description 发布条目内容
// @Param app form int true "当前App编号"
// @Param uid form int true "用户id"
// @Param chanId form int true "频道id"
// @Param token form string true "登陆成功token"
// @Param content form string true 文章内容"
// @Param imgs form string true "图片的地址,url之间用，分割"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.SubmitStatus
// @router /submit [post]
func (this *ImgTxtLiveController) Submit() {
	fmt.Println("run ImgTxtLiveController Submit")
	resStatus := &models.ResStatus{}
	startStatus := &models.SubmitStatus{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title close
// @Description 关闭直播
// @Param app form int true "当前App编号"
// @Param uid form int true "用户id"
// @Param chanId form int true "频道id"
// @Param token form string true "登陆成功token"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.CloseStatus
// @router /close [post]
func (this *ImgTxtLiveController) Close() {
	fmt.Println("run ImgTxtLiveController Stop")
	resStatus := &models.ResStatus{}
	startStatus := &models.CloseStatus{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}